<?php
namespace Homework8;

class Node {
	
	private $label;
	private $edges;			/* Node needs to know the connected edges and the edges to the neighbor */
	private $visited;
	private $discoveredTime;
	private $exploredTime;
	private $discovered;
	private $explored;
	private $predecessor;
	private $cost;
	
	public function __construct($label = null, $visited = false) {
		$this->label 			= $label;
		$this->visited 			= false;
		$this->discoveredTime 	= 0;
		$this->exploredTime		= 0;
		$this->discovered		= false;
		$this->explored			= false;
		$this->edges 			= array();
		$this->predecessor		= null;
		$this->cost				= 0;
	}
	
	public function setLabel($label) {
		$this->label = $label;
	}
	
	public function getLabel() {
		
		return $this->label;
	}
	
	public function addEdge(Edge $edge, $directed = true) {
		if (!$directed && $this == $edge->getTo()) {
			$this->edges[$edge->getFrom()->getLabel()] = $edge;
		} else {
			$this->edges[$edge->getTo()->getLabel()] = $edge;
		}
	}
	
	public function getEdges() {
		
		return $this->edges;
	}
	
	public function setVisited($visited = true) {
		$this->visited = $visited;
		
		return $this;
	}
	
	public function isVisited() {
		
		return $this->visited;
	}
	
	public function setDiscoveredTime($discoveredTime) {
		$this->discoveredTime = $discoveredTime;
		
		return $this;
	}
	
	public function getDiscoveredTime() {
		
		return $this->discoveredTime;
	}
	
	public function setExploredTime($exploredTime) {
		$this->exploredTime = $exploredTime;
		
		return $this;
	}
	
	public function getExploredTime() {
		
		return $this->exploredTime;
	}
	
	public function setDiscovered($discovered = true) {
		$this->discovered = $discovered;
	}
	
	public function isDiscovered() {
		
		return (bool)$this->discovered;
	}
	
	public function setExplored($explored = true) {
		$this->explored = $explored;
	}
	
	public function isExplored() {
		
		return (bool)$this->explored;
	}
	
	public function setPredecessor(Node $node) {
		$this->predecessor = $node;
	}
	
	public function getPredecessor() {
		
		return $this->predecessor;
	}
	
	public function setCost($cost) {
		$this->cost = $cost;
	}
	
	public function getCost() {
		
		return $this->cost;
	}
}